package com.hnkywl.sts.service.report;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.hnkywl.sts.dao.report.PjkcDao;
import com.hnkywl.sts.dao.report.YdcbDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-6-15
 * Time: 下午9:23
 * To change this template use File | Settings | File Templates.
 */
@Service
public class YdcbService {
    private YdcbDao ydcbDao;

    /**
     * 财务库存报表
     *
     * @param gsid
     * @param nowDate
     * @return
     */
    public String ydcbList(Long gsid,Date nowDate,String code,String ggxh,String name, Integer pageNo, Integer pageSize) {
        Map<String, Object> result = ydcbDao.ydcbList(gsid,nowDate,code,ggxh,name,pageNo,pageSize);
        Integer total=(Integer)result.get("total");
        List<Map> rows = (List<Map>)result.get("rows");
        Gson gson = new GsonBuilder().create();
        String rowsJson = gson.toJson(rows);
        String json = "{\"rows\":" + rowsJson +",\"total\":"+total+ "}";
        return json;
    }


    @Autowired
    public void setYdcbDao(YdcbDao ydcbDao) {
        this.ydcbDao = ydcbDao;
    }
}
